package top.noteday.controller;

import entity.result.EntityResult;
import entity.user.UserDto;
import entity.user.UserVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.noteday.provider.VersionService;
import top.noteday.provider.user.UserService;
import utils.common.StrUtil;

@RestController
@RequestMapping(value = "/backstage/user")
public class UserController {
    private final Logger LOGGER = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;

    /*@Value("${kalimdor.access.port}")
    private String port;*/

    @PostMapping("/login")
    public EntityResult<UserDto> login(UserVo vo) {
        LOGGER.info("登录接口参数{} = ", vo);

        EntityResult<UserDto> result = new EntityResult<>();
        StrUtil.paramIsCorrect(StrUtil.isNotEmpty(vo.getLoginName()), "登录账号不可为空");
        StrUtil.paramIsCorrect(StrUtil.isNotEmpty(vo.getLoginPwd()), "登录密码不可为空");
        StrUtil.paramIsCorrect(vo.getLoginPwd().length() <= 18 && vo.getLoginPwd().length() >= 6, "密码错误");
        StrUtil.isCorrectPassword(vo.getLoginPwd());
        result = userService.login(vo);
        return result;

    }
    //userService.getUrl("zzzzzzzzzzzzzz");
/* Map<String, String> map = new HashMap<>();
        map.put("aaa", "111");
        map.put("bbb", "222");
        System.out.println(port);*/
    //return port;// + versionService.demoPost(map);
}
